// 检查用户名格式
function checkUsername() {
    "use strict"; // 函数级严格模式
    var elementById = document.getElementById("usernameInput");
    var value = elementById.value;
    var elementById1 = document.getElementById("usernameMsg");
    var usernameReg = /^[a-zA-Z ][a-zA-Z-0-9]{5,9}$/;
    if (!usernameReg.test(value)) {
        elementById1.innerText = "账号格式错误！";
        return false;
    } else {
        elementById1.innerText = "账号格式正确！";
        elementById1.style.color = "green";
        return true;
    }
}

// 检查密码格式
function checkUserPwd() {
    "use strict"; // 函数级严格模式
    var elementById = document.getElementById("userPwdInput");
    var value = elementById.value;
    var elementById1 = document.getElementById("userPwdMsg");
    var passwordReg = /^[a-zA-Z0-9 _\-@#&*]{6,12}$/;
    if (!passwordReg.test(value)) {
        elementById1.innerText = "密码格式错误！";
        return false;
    } else {
        elementById1.innerText = "密码格式正确！";
        elementById1.style.color = "green";
        return true;
    }
}

// 检查确认密码是否一致
function checkReUserPwd() {
    "use strict"; // 函数级严格模式
    var elementById = document.getElementById("userPwdInput");
    var value = elementById.value;
    var elementById1 = document.getElementById("reUserPwdInput");
    var confirm = elementById1.value;
    var elementById2 = document.getElementById("reUserPwdMsg");
    if (value === confirm) {
        elementById2.innerText = "OK";
        elementById2.style.color = "green";
        return true;
    } else {
        elementById2.innerText = "密码不一致";
        elementById2.style.color = "red";
        return false;
    }
}

// 检查表单是否通过验证
function checkForm() {
    "use strict"; // 函数级严格模式
    var b = checkUsername();
    var b1 = checkUserPwd();
    var b2 = checkReUserPwd();
    return b && b1 && b2;
}